/**************************************************************************/
/*                                                                        */
/* Copyright (c) SinoEmbed Technology Co.,Ltd.           */
/*  */
/*                                                                        */
/*                                                                        */
/*    created:    2012-8-18                                             */ 
/*    filename:                                             */ 
/*    author:     Derek Huang                                                  */  
/*    purpose:                                                            */ 
/*                                                                        */
/* ************************************************************************/
#include "VirtualDiscPlayer.h"
CVirtualDiscPlayerApp VirtualDiscPlayerApp;
//#define IVIDEO_XML_SKIN_PATH	_T("\\SDMMC\\IntApp\\Skins\\Video.xml")
//#define IVIDEO_XML_SKIN_PATH	_T("\\ResidentFlash2\\IntApp\\Skins\\Video.xml")
//#define IVIDEO_XML_SKIN_PATH	_T("\\Nand\\IntApp\\Skins\\Video.xml")
//#define IVIDEO_XML_SKIN_PATH	_T("\\ResidentFlash2\\IntApp30\\Skins\\Video.xml")
//extern void GetRectFromString(	TCHAR* strRect,  RECT *rect);

#define WM_SOURCE_SHOWWINDOW (WM_USER + 251)
CVirtualDiscPlayerApp::CVirtualDiscPlayerApp()
{
	m_pMainWin = NULL;
}

CVirtualDiscPlayerApp::~CVirtualDiscPlayerApp()
{
	CoUninitialize();	
}
BOOL CVirtualDiscPlayerApp::Init()
{

	CoInitializeEx(NULL, COINIT_MULTITHREADED );
	HANDLE Handle = CreateMutex(NULL,FALSE,L"VirtualDisc");
	if (GetLastError() != ERROR_ALREADY_EXISTS)
	{

		RECT rtVideo = {0, 0, 800, 480};
		m_pMainWin = new CVirtualDiscPlayerDlg();
		if( m_pMainWin )
		{
			if(m_pMainWin->Create(rtVideo.left, rtVideo.top, rtVideo.right - rtVideo.left, 
				rtVideo.bottom - rtVideo.top, 0, 0, 0, 0))
			{
				m_pMainWin->Show();
				return TRUE;
			}
			else
			{
				return FALSE;
			}	
		}
		else
		{
			return FALSE;
		}
		return CMzApp::Init();
	}
	else
	{
		HWND hFileBrowserWnd = ::FindWindow(NULL, L"CVirtualDiscPlayerDlg");
		if(hFileBrowserWnd)
		{
			::ShowWindow(hFileBrowserWnd, TRUE);
			SetForegroundWindow(hFileBrowserWnd);
		}
//		::SendMessage(hFileBrowserWnd, WM_SOURCE_SHOWWINDOW, (WPARAM)1, 0);
		return 0;
	}
}
